﻿using Midi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestApp1
{
    public static class Extension
    {
        public static void SendMessage(this OutputDevice device,ChannelMessage msg)
        {
            ControlChangeMessage ccm =msg as ControlChangeMessage;
            if (ccm != null)
                device.SendControlChange(msg.Channel, ccm.Control, ccm.Value);

            NoteOnMessage nom = msg as NoteOnMessage;
            if (nom != null)
                device.SendNoteOn(msg.Channel,nom.Pitch,nom.Velocity);

            NoteOffMessage noffm = msg as NoteOffMessage;
            if (noffm != null)
                device.SendNoteOff(msg.Channel,noffm.Pitch,noffm.Velocity);

        }

    }
}
